package com.industry.examinaion.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.industry.examinaion.dal.dataobject.ExaminaionPaper;
import com.industry.examinaion.dal.dataobject.ExaminaionPaperQuestion;
import com.industry.examinaion.service.ExaminaionPaperQuestionService;
import com.industry.framework.common.Result;
import com.industry.framework.core.annountions.monitor.IdooMonitorService;
import com.industry.framework.core.exception.CoreInvalidateArgsException;
import com.industry.framework.core.generic.AbstractCoreGenericController;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("examinaion-paper-question")
public class ExaminaionPaperQuestionController extends AbstractCoreGenericController<ExaminaionPaperQuestion,String> {

    @Resource
    ExaminaionPaperQuestionService examinaionPaperQuestionService;

    @GetMapping("/query-details-cust/{id}")
    @IdooMonitorService("详情查询")
    //根据试卷查询 题目内容
    public Result<List<ExaminaionPaperQuestion>> queryDetailsCust(@PathVariable("id") String id) {
        //根据试卷id  查询题目
        if(StringUtils.isEmpty(id)){
            throw new CoreInvalidateArgsException("CoreGenericController [queryDetails] defind args id");
        }
        List<ExaminaionPaperQuestion> list
                = examinaionPaperQuestionService.getMapper().selectList(
                        Wrappers.lambdaQuery(ExaminaionPaperQuestion.class).eq(ExaminaionPaperQuestion::getExaminaionPaperId, id)
        );
        return Result.success(list);
    }
}
